package com.wu.llpsw.effect.buff;


import com.wu.llpsw.yuanli.energy.yuanliManager;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.effect.MobEffectCategory;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;

import java.util.Random;

//恢复元力的效果:凝元
public class ningyuan_effect extends BaseEffect {
    public ningyuan_effect(MobEffectCategory type, int color, boolean isInstant) {
        super(type, color, isInstant);
    }

    //buff隔多久生效一次
    @Override
    protected boolean canApplyEffect(int remainingTicks, int level) {
        return remainingTicks % 5 == 0;
    }

    //效果作用用于身上的效果
    @Override
    public void applyEffectTick(LivingEntity entity, int value) {
        if(entity instanceof ServerPlayer){
            Player player=(Player) entity;
            if(yuanliManager.getNowYuanLi(player)<yuanliManager.getMaxYuanLi(player)){
                Random ran = new Random();
                int co = ran.nextInt(2);
                yuanliManager.use(player,co);
            }
        }
    }


    //申明是debuff还是buff
    @Override
    public boolean isBeneficial() {
        return false;
    }
}
